<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java I/O模型详解：BIO、NIO与AIO</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            background-color: #f9fafb;
            color: #1f2937;
            line-height: 1.6;
        }
        
        .hero {
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
            color: white;
        }
        
        .code-block {
            background-color: #1e293b;
            color: #e2e8f0;
            border-radius: 0.5rem;
            overflow-x: auto;
        }
        
        .compare-table {
            background: white;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
        
        .compare-table th {
            background-color: #f3f4f6;
            font-weight: 600;
        }
        
        .section-card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            background: white;
            border-radius: 0.75rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
        
        .section-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        
        .feature-icon {
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
        }
        
        .first-letter {
            float: left;
            font-size: 3.5rem;
            line-height: 1;
            margin-right: 0.5rem;
            margin-top: 0.25rem;
            color: #3b82f6;
            font-family: 'Noto Serif SC', serif;
            font-weight: 700;
        }
        
        h1, h2, h3 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        
        .mermaid {
            background: white;
            border-radius: 0.75rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero py-20 px-6 md:px-16 lg:px-32">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-2/3 md:pr-10">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6">深入理解Java I/O模型</h1>
                    <p class="text-xl md:text-2xl text-blue-100 mb-8">探索BIO、NIO与AIO的核心概念、应用场景与实现差异</p>
                    <div class="flex items-center">
                        <div class="bg-blue-500 text-white px-4 py-2 rounded-full text-sm font-medium inline-flex items-center">
                            <i class="fas fa-laptop-code mr-2"></i>
                            Java编程
                        </div>
                        <div class="bg-blue-400 text-white px-4 py-2 rounded-full text-sm font-medium ml-2 inline-flex items-center">
                            <i class="fas fa-network-wired mr-2"></i>
                            网络编程
                        </div>
                    </div>
                </div>
                <div class="md:w-1/3 mt-8 md:mt-0">
                    <img src="https://cdn.pixabay.com/photo/2020/05/31/09/40/online-course-5242018_1280.jpg" alt="Java I/O" class="rounded-lg shadow-xl transform rotate-2">
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-5xl mx-auto px-6 py-12 md:px-8">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold mb-4">Java I/O模型的核心概念</h2>
                <p class="text-gray-600 max-w-3xl mx-auto">在Java编程中，BIO（Blocking I/O）、NIO（Non-blocking I/O）、和AIO（Asynchronous I/O）分别代表不同的I/O模型。这三种模型提供了不同的方式来处理网络通信、文件操作等I/O任务。理解这三种I/O模型的特性及其在Java中的实现，对于开发高效、可靠的应用程序非常重要。</p>
            </div>

            <!-- Visualization -->
            <div class="mermaid mb-16">
                graph TD
                    A[Java I/O模型] --> B[BIO\n阻塞式I/O]
                    A --> C[NIO\n非阻塞式I/O]
                    A --> D[AIO\n异步I/O]
                    B --> E[同步阻塞]
                    B --> F[每个连接独立线程]
                    C --> G[同步非阻塞]
                    C --> H[多路复用]
                    D --> I[异步非阻塞]
                    D --> J[回调机制]
            </div>
        </section>

        <!-- BIO Section -->
        <section class="mb-20">
            <div class="section-card p-8">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-red-100 text-red-600">
                        <i class="fas fa-stopwatch fa-lg"></i>
                    </div>
                    <h2 class="text-2xl font-bold">1. BIO（Blocking I/O）</h2>
                </div>
                
                <div class="ml-16">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">1.1 概念</h3>
                    <p class="mb-6"><span class="first-letter">B</span>IO，全称为<strong>Blocking I/O</strong>，是一种<strong>阻塞式</strong>的I/O模型。在BIO模型中，I/O操作是同步的且会阻塞调用线程，直到操作完成为止。这意味着在一个线程中发起I/O操作后，该线程将被挂起，直到I/O操作完成。这种方式对于简单的应用场景来说是足够的，但当需要处理大量并发连接时，效率和资源利用率会受到影响。</p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">1.2 特性</h3>
                    <ul class="mb-6 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-red-500 mt-1 mr-2"></i>
                            <span><strong>阻塞式</strong>：每个I/O操作都会阻塞当前线程，直到操作完成。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-red-500 mt-1 mr-2"></i>
                            <span><strong>同步调用</strong>：I/O操作按顺序执行，调用方需要等待操作完成。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-red-500 mt-1 mr-2"></i>
                            <span><strong>线程占用</strong>：每个连接需要一个独立的线程来处理I/O操作。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-red-500 mt-1 mr-2"></i>
                            <span><strong>简单易用</strong>：编程模型简单，容易理解和实现。</span>
                        </li>
                    </ul>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-up text-green-500 mr-2"></i>
                                优点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>编程简单，逻辑清晰，适合小规模应用。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>每个请求在一个独立的线程中处理，便于隔离和调试。</span>
                                </li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-down text-red-500 mr-2"></i>
                                缺点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>线程资源消耗大，处理大量并发连接时效率低。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>线程上下文切换开销大，容易导致性能瓶颈。</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">1.4 应用场景</h3>
                    <div class="mb-6 bg-blue-50 p-4 rounded-lg">
                        <p>适用于连接数量较少、请求响应时间较长的应用，如文件上传/下载服务。</p>
                        <p class="mt-2">小型应用或资源有限的环境中，BIO是一个较为简单且可行的选择。</p>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">1.5 实现示例</h3>
                    <p class="mb-4">在Java中，传统的<code class="bg-gray-100 px-2 py-1 rounded">Socket</code>和<code class="bg-gray-100 px-2 py-1 rounded">ServerSocket</code>类就是BIO模型的实现。例如，一个简单的BIO服务器实现如下：</p>
                    <div class="code-block p-4 mb-6 rounded-lg">
                        <pre><code class="text-sm">import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class BIOServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8080);
        System.out.println("BIO Server started, listening on port 8080");

        while (true) {
            Socket clientSocket = serverSocket.accept(); // 阻塞
            new Thread(new ClientHandler(clientSocket)).start(); // 每个连接一个线程
        }
    }
}

class ClientHandler implements Runnable {
    private Socket clientSocket;

    public ClientHandler(Socket socket) {
        this.clientSocket = socket;
    }

    @Override
    public void run() {
        try {
            // 处理客户端请求
            InputStream input = clientSocket.getInputStream();
            OutputStream output = clientSocket.getOutputStream();
            // 读取和写入数据
            ...
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- NIO Section -->
        <section class="mb-20">
            <div class="section-card p-8">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-blue-100 text-blue-600">
                        <i class="fas fa-bolt fa-lg"></i>
                    </div>
                    <h2 class="text-2xl font-bold">2. NIO（Non-blocking I/O）</h2>
                </div>
                
                <div class="ml-16">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">2.1 概念</h3>
                    <p class="mb-6"><span class="first-letter">N</span>IO，全称为<strong>Non-blocking I/O</strong>，是一种<strong>非阻塞式</strong>的I/O模型。在NIO中，通道（Channel）和缓冲区（Buffer）是核心概念，I/O操作不再阻塞调用线程。NIO通过选择器（Selector）实现了多路复用，允许一个线程处理多个连接。这使得NIO能够在高并发场景下提供更好的性能和资源利用率。</p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">2.2 特性</h3>
                    <ul class="mb-6 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                            <span><strong>非阻塞式</strong>：I/O操作不会阻塞线程，线程可以在等待I/O事件时处理其他任务。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                            <span><strong>单线程多连接</strong>：一个线程可以处理多个I/O连接，通过选择器轮询I/O事件。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                            <span><strong>基于通道和缓冲区</strong>：数据通过通道传输，缓冲区用于存储和操作数据。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                            <span><strong>高效性</strong>：减少了线程数量和上下文切换开销，提升了系统性能。</span>
                        </li>
                    </ul>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-up text-green-500 mr-2"></i>
                                优点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>高并发性能好，适用于大规模连接场景。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>资源利用率高，线程管理开销小。</span>
                                </li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-down text-red-500 mr-2"></i>
                                缺点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>编程复杂度高，调试和维护难度大。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>需要理解通道、缓冲区、选择器等概念。</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">2.4 应用场景</h3>
                    <div class="mb-6 bg-blue-50 p-4 rounded-lg">
                        <p>大型网络服务器，如Web服务器、游戏服务器。</p>
                        <p class="mt-2">高并发场景下的应用程序，如聊天系统、在线视频流服务。</p>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">2.5 实现示例</h3>
                    <p class="mb-4">在Java中，NIO的核心组件包括<code class="bg-gray-100 px-2 py-1 rounded">Channel</code>、<code class="bg-gray-100 px-2 py-1 rounded">Buffer</code>和<code class="bg-gray-100 px-2 py-1 rounded">Selector</code>。以下是一个简单的NIO服务器示例：</p>
                    <div class="code-block p-4 mb-6 rounded-lg">
                        <pre><code class="text-sm">import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;

public class NIOServer {
    public static void main(String[] args) throws IOException {
        Selector selector = Selector.open();
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        serverChannel.bind(new InetSocketAddress(8080));
        serverChannel.configureBlocking(false);
        serverChannel.register(selector, SelectionKey.OP_ACCEPT);
        System.out.println("NIO Server started, listening on port 8080");

        while (true) {
            selector.select(); // 阻塞等待就绪的通道
            Iterator&lt;SelectionKey&gt; keys = selector.selectedKeys().iterator();

            while (keys.hasNext()) {
                SelectionKey key = keys.next();
                keys.remove();

                if (key.isAcceptable()) {
                    SocketChannel clientChannel = serverChannel.accept();
                    clientChannel.configureBlocking(false);
                    clientChannel.register(selector, SelectionKey.OP_READ);
                } else if (key.isReadable()) {
                    SocketChannel clientChannel = (SocketChannel) key.channel();
                    ByteBuffer buffer = ByteBuffer.allocate(1024);
                    clientChannel.read(buffer);
                    // 处理读取的数据
                    ...
                }
            }
        }
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- AIO Section -->
        <section class="mb-20">
            <div class="section-card p-8">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-green-100 text-green-600">
                        <i class="fas fa-rocket fa-lg"></i>
                    </div>
                    <h2 class="text-2xl font-bold">3. AIO（Asynchronous I/O）</h2>
                </div>
                
                <div class="ml-16">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">3.1 概念</h3>
                    <p class="mb-6"><span class="first-letter">A</span>IO，全称为<strong>Asynchronous I/O</strong>，是一种<strong>异步非阻塞</strong>的I/O模型。AIO引入了异步通道和回调机制，I/O操作的结果会通过回调函数通知应用程序。这种模型下，I/O操作是完全异步的，调用方不需要等待I/O完成，而是通过事件驱动的方式处理I/O结果。</p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">3.2 特性</h3>
                    <ul class="mb-6 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>异步非阻塞</strong>：I/O操作立即返回，结果通过回调通知。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>回调机制</strong>：使用回调函数处理I/O操作结果，提高了系统的响应能力。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>支持高并发</strong>：有效减少了阻塞等待，提高了系统的吞吐量。</span>
                        </li>
                    </ul>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-up text-green-500 mr-2"></i>
                                优点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>极高的并发处理能力，适用于超大规模连接场景。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                    <span>异步事件驱动，减少了资源消耗。</span>
                                </li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-thumbs-down text-red-500 mr-2"></i>
                                缺点
                            </h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>编程复杂度极高，需要深入理解异步处理和回调机制。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                                    <span>不适合简单的同步场景，可能导致代码难以维护。</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">3.4 应用场景</h3>
                    <div class="mb-6 bg-blue-50 p-4 rounded-lg">
                        <p>高性能服务器和分布式系统，如云计算平台、大型电商系统。</p>
                        <p class="mt-2">实时性要求高的应用，如金融交易系统、在线游戏服务。</p>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">3.5 实现示例</h3>
                    <p class="mb-4">在Java中，AIO由<code class="bg-gray-100 px-2 py-1 rounded">AsynchronousSocketChannel</code>和<code class="bg-gray-100 px-2 py-1 rounded">AsynchronousServerSocketChannel</code>实现。以下是一个简单的AIO服务器示例：</p>
                    <div class="code-block p-4 mb-6 rounded-lg">
                        <pre><code class="text-sm">import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;

public class AIOServer {
    public static void main(String[] args) throws IOException {
        AsynchronousServerSocketChannel serverChannel = AsynchronousServerSocketChannel.open();
        serverChannel.bind(new InetSocketAddress(8080));
        System.out.println("AIO Server started, listening on port 8080");

        serverChannel.accept(null, new CompletionHandler&lt;AsynchronousSocketChannel, Void&gt;() {
            @Override
            public void completed(AsynchronousSocketChannel clientChannel, Void attachment) {
                // 继续接收下一个连接
                serverChannel.accept(null, this);

                // 处理当前连接
                ByteBuffer buffer = ByteBuffer.allocate(1024);
                clientChannel.read(buffer, buffer, new CompletionHandler&lt;Integer, ByteBuffer&gt;() {
                    @Override
                    public void completed(Integer result, ByteBuffer buffer) {
                        // 处理读取的数据
                        buffer.flip();
                        clientChannel.write(buffer, buffer, new CompletionHandler&lt;Integer, ByteBuffer&gt;() {
                            @Override
                            public void completed(Integer result, ByteBuffer buffer) {
                                // 完成写操作
                                ...
                            }

                            @Override
                            public void failed(Throwable exc, ByteBuffer buffer) {
                                // 处理写操作失败
                                ...
                            }
                        });
                    }

                    @Override
                    public void failed(Throwable exc, ByteBuffer buffer) {
                        // 处理读操作失败
                        ...
                    }
                });
            }

            @Override
            public void failed(Throwable exc, Void attachment) {
                // 处理连接失败
                ...
            }
        });

        // 保持主线程运行
        while (true) {
            Thread.sleep(1000);
        }
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-12">
            <div class="section-card p-8">
                <h2 class="text-2xl font-bold mb-8 text-center">4. BIO、NIO、AIO的比较</h2>
                
                <div class="overflow-x-auto">
                    <table class="compare-table w-full">
                        <thead>
                            <tr>
                                <th class="px-6 py-3 text-left">特性</th>
                                <th class="px-6 py-3 text-left">BIO</th>
                                <th class="px-6 py-3 text-left">NIO</th>
                                <th class="px-6 py-3 text-left">AIO</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 font-medium">模型</td>
                                <td class="px-6 py-4">阻塞式I/O</td>
                                <td class="px-6 py-4">非阻塞式I/O</td>
                                <td class="px-6 py-4">异步非阻塞I/O</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 font-medium">阻塞行为</td>
                                <td class="px-6 py-4">阻塞调用线程</td>
                                <td class="px-6 py-4">不阻塞，使用选择器轮询</td>
                                <td class="px-6 py-4">不阻塞，使用回调机制</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 font-medium">线程模型</td>
                                <td class="px-6 py-4">每个连接一个线程</td>
                                <td class="px-6 py-4">单线程处理多个连接</td>
                                <td class="px-6 py-4">事件驱动，回调处理结果</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 font-medium">性能</td>
                                <td class="px-6 py-4">适合小规模连接</td>
                                <td class="px-6 py-4">适合高并发，较高性能</td>
                                <td class="px-6 py-4">极高并发，最高性能</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 font-medium">编程复杂度</td>
                                <td class="px-6 py-4">简单</td>
                                <td class="px-6 py-4">中等复杂</td>
                                <td class="px-6 py-4">高复杂度</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 font-medium">使用场景</td>
                                <td class="px-6 py-4">小型应用，简单I/O操作</td>
                                <td class="px-6 py-4">大型服务器，高并发场景</td>
                                <td class="px-6 py-4">超大规模，高性能实时应用</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                
                <div class="mt-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800">性能对比图示</h3>
                    <div class="bg-white p-4 rounded-lg">
                        <div class="flex justify-center items-center h-64">
                            <div class="w-full max-w-2xl">
                                <div class="flex items-end h-48">
                                    <div class="flex-1 flex flex-col items-center">
                                        <div class="bg-red-500 w-16 rounded-t" style="height: 30%;"></div>
                                        <div class="mt-2 text-sm text-gray-600">BIO</div>
                                    </div>
                                    <div class="flex-1 flex flex-col items-center">
                                        <div class="bg-blue-500 w-16 rounded-t" style="height: 70%;"></div>
                                        <div class="mt-2 text-sm text-gray-600">NIO</div>
                                    </div>
                                    <div class="flex-1 flex flex-col items-center">
                                        <div class="bg-green-500 w-16 rounded-t" style="height: 100%;"></div>
                                        <div class="mt-2 text-sm text-gray-600">AIO</div>
                                    </div>
                                </div>
                                <div class="flex justify-between mt-2">
                                    <div class="text-xs text-gray-500 ml-8">低性能</div>
                                    <div class="text-xs text-gray-500">中等性能</div>
                                    <div class="text-xs text-gray-500 mr-8">高性能</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-8">
            <div class="section-card p-8">
                <h2 class="text-2xl font-bold mb-6 text-center">技术选型建议</h2>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-red-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-3 text-red-700 flex items-center">
                            <i class="fas fa-stopwatch mr-2"></i>
                            BIO适用场景
                        </h3>
                        <ul class="space-y-2 text-red-800">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>连接数较少（几十到几百）</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>开发周期短，需要快速实现</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>对性能要求不高的内部系统</span>
                            </li>
                        </ul>
                    </div>
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-3 text-blue-700 flex items-center">
                            <i class="fas fa-bolt mr-2"></i>
                            NIO适用场景
                        </h3>
                        <ul class="space-y-2 text-blue-800">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>高并发连接（数千到数万）</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>需要高效率的网络服务器</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>实时性要求较高的应用</span>
                            </li>
                        </ul>
                    </div>
                    <div class="bg-green-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold mb-3 text-green-700 flex items-center">
                            <i class="fas fa-rocket mr-2"></i>
                            AIO适用场景
                        </h3>
                        <ul class="space-y-2 text-green-800">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>极高性能要求的系统</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>大规模分布式系统</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2"></i>
                                <span>对延迟极其敏感的应用</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>